如何用matlab求曲线面积?

您所在的位置:网站首页 matlab 计算函数积分 如何用matlab求曲线面积?

如何用matlab求曲线面积?

2023-03-24 03:22| 来源: 网络整理| 查看: 265

数学公式:

f(x)=5x^{2}+6\\ g(x)=\int \, f(x) \, \text{d}x = \frac{5x^3}{3} + 6x\\ s = \int_{1}^{14} \, f(x) \, \text{d}x = g(x)\vert_{1}^{14}=g(14) - g(1)

需要用到 MATLAB 的 Symbolic Math Toolbox :

clear clc syms x f f = 5*x^2 + 6 disp('画出函数f(x)的图像:') h = matlabFunction(f) fplot(@(x) h(x),[0 15],'b') disp('计算出函数f(x)的不定积分g(x):') g = int(f, x) disp('计算出函数f(x)在区间[1 14]的定积分:') s1 = subs(g, x, 14) - subs(g, x, 1) disp('一步计算定积分也可以') s2 = int(f, x, 1, 14) disp('判断两次计算结果 s1 和 s2 是否相等') s1 == s2

运行结果:

图 1:计算结果

函数图像:

图 2:函数 f(x) 的图像

说明:

\texttt{int(f, x)} 用于计算函数 f(x) 的不定积分函数 g(x) ;\texttt{int(f, x, a, b)} 用于计算函数 f(x) 在区间 [a,\, b] 的定积分;\texttt{subs(g, x, a)} 用于计算函数 g(x) 在 x = a 处的值;\texttt{matlabFunction(f)} 将符号表达式 \texttt{f} 转为函数句柄 \texttt{h(x)} ,供 fplot 画出 \texttt{h(x)} 的图像。


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3